# -*- coding: utf-8 -*-

from ui.presenter import BasePresenter
from ui.platform_adapter import PlatformAdapter
from model.syssettings import SysSettings
from model.gamestate import Phase


class PresenterMock(BasePresenter):
    def __init__(self, new_phase, prev_phase=None, game_state=None):
        self.new_phase = new_phase
        self.prev_phase = prev_phase
        self.is_phase_changed = False
        self.game_state = game_state
        self.settings = SysSettings('./data/config_tests.ini')
        self.adapter = PlatformAdapter.get_adapter()

    def change_phase(self, phase):
        if self.is_phase_changed:
            raise Exception('phase chainged twice')
        self.is_phase_changed = True
        if phase != self.new_phase and phase != self.prev_phase:
            raise Exception('''Incorrect phase set in phase_change:
                expected {} or {} found {}'''.format(self.new_phase,
                                                     self.prev_phase, phase))

    def restart(self):
        self.change_phase(Phase.WELCOME)
